diff --git a/keyserver/src/responders/website-responders.js b/keyserver/src/responders/website-responders.js --- a/keyserver/src/responders/website-responders.js +++ b/keyserver/src/responders/website-responders.js @@ -94,6 +94,7 @@ +cssInclude: string, +olmFilename: string, +sqljsFilename: string, + +commQueryExecutorFileName: string, +opaqueURL: string, }; let assetInfo: ?AssetInfo = null; @@ -109,6 +110,7 @@ cssInclude: '', olmFilename: '', sqljsFilename: '', + commQueryCreatorFileName: '', opaqueURL: 'http://localhost:8080/opaque-ke.wasm', }; return assetInfo; @@ -133,6 +135,7 @@ `, olmFilename: manifest['olm.wasm'], sqljsFilename: webworkersManifest['sql-wasm.wasm'], + commQueryExecutorFileName: webworkersManifest['CommQueryExecutor.wasm'], opaqueURL: `compiled/${manifest['comm_opaque2_wasm_bg.wasm']}`, }; return assetInfo; @@ -489,8 +492,15 @@ }; })(); - const { jsURL, fontsURL, cssInclude, olmFilename, sqljsFilename, opaqueURL } = - await assetInfoPromise; + const { + jsURL, + fontsURL, + cssInclude, + olmFilename, + sqljsFilename, + opaqueURL, + commQueryExecutorFileName, + } = await assetInfoPromise; // prettier-ignore res.write(html` @@ -598,6 +608,7 @@ var baseURL = "${baseURL}"; var olmFilename = "${olmFilename}"; var sqljsFilename = "${sqljsFilename}"; + var commQueryExecutorFileName = "${commQueryExecutorFileName}"; var opaqueURL = "${opaqueURL}"; diff --git a/web/database/database-module-provider.js b/web/database/database-module-provider.js --- a/web/database/database-module-provider.js +++ b/web/database/database-module-provider.js @@ -11,6 +11,7 @@ } from '../types/worker-types.js'; declare var sqljsFilename: string; +declare var commQueryExecutorFileName: string; declare var preloadedState: AppState; const databaseStatuses = Object.freeze({ @@ -61,6 +62,7 @@ sqljsFilePath: `${origin}${SQLJS_FILE_PATH}`, sqljsFilename, encryptionKey, + commQueryExecutorFileName, }); this.status = databaseStatuses.initSuccess; console.info('Database initialization success'); diff --git a/web/database/worker/db-worker.js b/web/database/worker/db-worker.js --- a/web/database/worker/db-worker.js +++ b/web/database/worker/db-worker.js @@ -19,6 +19,7 @@ type WorkerRequestProxyMessage, workerWriteRequests, } from '../../types/worker-types.js'; +import Module from '../_generated/CommQueryExecutor.js'; import { migrate, setupSQLiteDB } from '../queries/db-queries.js'; import { getAllDrafts, @@ -62,8 +63,26 @@ async function initDatabase( sqljsFilePath: string, sqljsFilename: ?string, + commQueryExecutorFileName: ?string, encryptionKeyJWK?: ?SubtleCrypto$JsonWebKey, ) { + console.log(commQueryExecutorFileName); + const dbModule = Module({ + locateFile: function (defaultFilename) { + if (commQueryExecutorFileName) { + return `${sqljsFilePath}/${commQueryExecutorFileName}`; + } + return `${sqljsFilePath}/${defaultFilename}`; + }, + }); + + try { + const result = dbModule.CommQueryExecutor.testDBOperation(); + console.log(result); + } catch (e) { + console.error(e); + } + if (encryptionKeyJWK) { encryptionKey = await importJWKKey(encryptionKeyJWK); } else { @@ -210,6 +229,7 @@ await initDatabase( message.sqljsFilePath, message.sqljsFilename, + message.commQueryExecutorFileName, message.encryptionKey, ); return undefined; diff --git a/web/types/worker-types.js b/web/types/worker-types.js --- a/web/types/worker-types.js +++ b/web/types/worker-types.js @@ -36,6 +36,7 @@ +type: 1, +sqljsFilePath: string, +sqljsFilename: ?string, + +commQueryExecutorFileName: ?string, +encryptionKey?: ?SubtleCrypto$JsonWebKey, };